import { Body, Controller, Post, Session, UseGuards } from '@nestjs/common';
import { SharedService } from './shared.service';
import { AuthGuard } from '@/common/guard/auth.guard';
import { UserQueryCfgDto } from '@/basedata/dto/create-basedatum.dto';
import { UpdateUserQueryCfgDto } from '@/basedata/dto/update-basedatum.dto';
import { DeleteDto, SqlQueryDto } from '@/common/type/app.dto';


@Controller('shared')
@UseGuards(AuthGuard)
export class SharedController {
  constructor(private readonly sharedService: SharedService) {}

  @Post('getFormFieldSelectOption')
  async getFormFieldSelectOption() {
    return await this.sharedService.getFormFieldSelectOption();
  }

  @Post('filterInvoiceFromCorpNam')
  async filterInvoiceFromCorpNam(@Body() dto: any) {
    return await this.sharedService.filterInvoiceFromCorpNam(dto);
  }

  @Post('saveuserquerycfg')
  async createUserQueryCfg(@Body() dto: UserQueryCfgDto, @Session() session: Record<string, any>) {
    dto.user_name = session['user']['name'];
    return await this.sharedService.saveUserQueryCfg(dto);
  }

  
  @Post('deleteuserquerycfg')
  async deleteUserQueryCfg(@Body() dto: DeleteDto) {
    return await this.sharedService.deleteUserQueryCfg(dto);
  }
  
  @Post('queryuserquerycfg')
  async queryUserQueryCfg(@Body() dto: SqlQueryDto, @Session() session: Record<string, any>) {
    return await this.sharedService.queryUserQueryCfg(dto, session['user']['name']);
  }


  /* @Post('getFeeFieldSelectOption')
  async getFeeFieldSelectOption() {
    return await this.sharedService.getFeeFieldSelectOption();
  } */
}
